<%- include header %>
<ul class="nav nav-pills">
    <li><a href="/partnerDynimic">语伴动态</a></li>
    <li ><a href="/findPartner">查找语伴</a></li>
    <li><a href="/myPartner">我的语伴</a></li>
    <li class="active"><a href="/myDynimic">我的动态</a></li>
</ul>

<form method="post" action="/addDynimic" style="margin-top:50px;margin-left: 90px">
    <script id="ucontainer" name="content" type="text/plain"></script>
    <input type="submit" value="发表动态" style="margin-top: 20px;margin-right: 430px;margin-bottom:10px;float: right" class="btn btn-danger">
</form>

<div  style="width:1000px ;margin:0 auto">
    <div class="portlet-title line">
        <div class="caption"><i class="icon-comments"></i>我的动态</div>
    </div>
    <% datas.forEach(function(data,index){ %>
    <div class="portlet-body" id="chats">
        <div class="scroller" data-height="435px" data-always-visible="1" data-rail-visible1="1">
            <ul class="chats">
                <li class="in">
                    <img class="avatar" alt="" src="media/image/1.jpg" />
                    <div class="message">
                        <span class="arrow"></span>
                        <a href="/partnerCenter?username=<%-data.user.username %>" class="name"><%- data.user.nickname %></a>
                        <span class="datatime">
                            <%- data.content %>
                        </span>
                        <span class="body"><%- data.date.format('yyyy-MM-dd')%><a href="/delDynimic?id=<%- data._id %>"> 删除</a></span>

                    </div>
                </li>
                <% data.replyDatas.forEach(function(replyData,index){ %>
                    <li class="in" style="margin-left: 50px">
                        <img class="avatar" alt="" src="media/image/avatar2.jpg" />
                        <div class="message">
                            <span class="arrow"></span>
                            <a href="/partnerCenter?username=<%-replyData.user.username %>" class="name"><%- replyData.user.nickname %></a>
                            <span class="datatime">
                                <%- replyData.content %>
                            </span>
                            <span class="body"><%- replyData.date.format('MM-dd hh:mm:ss')%><a> 回复</a><a href="/delDynimicReply?id=<%-replyData._id %>"> 删除</a></span>
                        </div>
                    </li>
                <% })%>
            </ul>
        </div>
        <form class="form-actions" method="post" action="/replyDynimic">
            <input type="hidden" value="<%- data._id %>" name="replyDynimic">
            <div class="input-append">
                <input style="width:800px" type="text" name="content"><button type="submit" class="btn">回复</button>
            </div>
        </form>
    </div>
    <% }) %>

</div>

<div class="span12">
    <div id="page1"></div>
</div>

<%- include footer %>
<script>
    function goDelete(id){
        var prompt=confirm("你确定删除吗？？");

        if(prompt){

            window.location.href="/delSchedule?id="+id;
        }
    }

    $(function(){
        //获得浏览器参数

        $.extend({
            getUrlVars: function(){
                var vars = [];
                var hash;
                var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                console.log(hashes);
                for(var i = 0; i < hashes.length; i++){
                    hash = hashes[i].split('=');
                    vars.push(hash[0]);
                    vars[hash[0]] = hash[1];
                }
                return vars;
            },
            getUrlVar: function(name){
                return $.getUrlVars()[name];
            }
        });

        //封装浏览器参数
        var composeUrlParams=function(){
            var param='';
            $.each($.getUrlVars(), function(i, item) {
                if(item!='num'){
                    var val=$.getUrlVar(item);
                    if(val) param += "&" + item+"="+val;
                }
            });
            return param;
        }
        var options = {
            currentPage:<%- page.num %>,                //当前页，css样式同其他页不同
            totalPages:<%- page.pageCount %>,           //总页数
            numberOfPages:5,                            //导航最多显示页数
            pageUrl: function(type, page, current) {    //页面跳转
                if(page!=<%- page.num %>){
                    return "/myDynimic?num="+ page+composeUrlParams();
                }

            }
        }
        $('#page1').bootstrapPaginator(options);
//        WdatePicker({eCont:'showDate',onpicked:function(dp){
//            alert('你选择的日期是:'+dp.cal.getDateStr());
//        }
//        })
    })


</script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('ucontainer',{
        initialFrameWidth:650,
        enableAutoSave:false,
        initialFrameHeight:171,
        saveInterval:60000
    });
</script>